package cate.game.play.skill.passive.exp;

import cate.common.util.XT;
import cate.game.play.config.PlayCfgArgs;
import cate.game.play.proce.action.ctx.SkillActionCtx;
import cate.game.play.skill.passive.PassiveHandler;

/**
 * 每次受击都有55%概率获得一个15%已损失生命值的护盾,每回合至多触发1次
 */
public class 血气方刚PH extends PassiveHandler {

	private int 概率;

	private int buff;

	//概率=5500&buff=??
	@Override
	public void parse(String code) {
		PlayCfgArgs args = new PlayCfgArgs(code);
		概率 = args.getInt("概率", 0);
		buff = args.getInt("buff", 0);
	}

	private int lastSettleRound;

	@Override
	public void afterSufferOneAttack(SkillActionCtx action, long totalDamage, boolean strike) {
		if (lastSettleRound >= action.getRound().index) {
			return;
		}
		if (XT.chance(概率)) {
			return;
		}
		lastSettleRound = action.getRound().index;
		skill.owner.buff.tryAddByTid(action, buff);
	}
}
